package cn.hxzy.controller;

import cn.hxzy.domain.Task;
import cn.hxzy.domain.TaskManager;
import cn.hxzy.response.R;
import cn.hxzy.response.StatusEnum;
import cn.hxzy.service.HomeworkService;
import cn.hxzy.service.TaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @作者:Baiyuxiang
 * @创建时间:2024-06-25 21:41:29
 */
@RestController
@RequestMapping("homework")
public class HomeworkController {
    @Autowired
    private TaskService taskService;
    @Autowired
    private HomeworkService homeworkService;
    /**
     * 导出作业资料
     *
     * @param file
     * @return
     */
    @PostMapping("/uploadProblem")
    public R uploadHomework(@RequestParam("file") MultipartFile file) {
        return null;
    }

    /**
     * 根据教师id获取学生作业列表
     * @param teacherId
     * @return
     */
    @GetMapping("getListTask/{id}")
    public R<List<Task>> getHomeworkListByTeacherId(@PathVariable("id") Long teacherId) {
        List<Task> taskList = taskService.getTaskListByTeacherId(teacherId);
        if (taskList != null) {
            return R.success(taskList);
        }
        return R.error(StatusEnum.PARAM_INVALID);
    }

    /**
     * 根据条件获取作业列表
     * @param classId
     * @param courseId
     * @param chapterId
     * @return
     */
    @GetMapping("getHomeworkList")
    public R getHomeworkList(@RequestParam(required = false) Long classId,@RequestParam(required = false)  Long courseId,@RequestParam(required = false)  Long chapterId){


        return null;
    }

    /**
     * 根据姓名查询作业
     * @param studentName
     * @return
     */
    @GetMapping("getHomeworkListByName")
    public R getHomeworkListByName(@RequestParam("studentName") String studentName){
        List<TaskManager> userIdByUserName = homeworkService.getUserIdByUserName(studentName);
        return R.success(userIdByUserName);
    }
}
